package com.magist.manage.web.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.magist.core.entity.Page;
import com.magist.core.service.SimpleServiceImpl;
import com.magist.manage.web.dao.BusinessLogMapper;
import com.magist.manage.web.entity.BusinessLog;
import com.magist.manage.web.service.BusinessLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class BusinessLogServiceImpl extends SimpleServiceImpl<BusinessLog> implements BusinessLogService{

	@Autowired
	private BusinessLogMapper businessLogMapper;


	@Override
	public PageInfo<BusinessLog> page(BusinessLog businessLog, Page page) {
		String orderBy = page.getSort() + " " + page.getOrder();
		if(StringUtils.isEmpty(orderBy.trim())) {
			PageHelper.startPage(page.getCurrPage(), page.getLimit());
		} else {
			PageHelper.startPage(page.getCurrPage(), page.getLimit(),orderBy);
		}
		List<BusinessLog> list = this.find(businessLog);
		PageInfo<BusinessLog> pageInfo = new PageInfo(list);
		return pageInfo;
	}

}